home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows5 / xwinc100.zip / CONTRIB-.00 / CONTRIB- / contrib / examples / Xaw / xlabel.c < prev    next >
C/C++ Source or Header  |  1991-01-22  |  3KB  |  98 lines

  1. /*
  2.  * This an example of how to use the Label widget.
  3.  *
  4.  * November 14, 1989 - Chris D. Peterson 
  5.  */
  6.  
  7. /*
  8.  * $XConsortium: xlabel.c,v 1.9 91/01/22 19:44:27 gildea Exp $
  9.  *
  10.  * Copyright 1989 Massachusetts Institute of Technology
  11.  *
  12.  * Permission to use, copy, modify, distribute, and sell this software and its
  13.  * documentation for any purpose is hereby granted without fee, provided that
  14.  * the above copyright notice appear in all copies and that both that
  15.  * copyright notice and this permission notice appear in supporting
  16.  * documentation, and that the name of M.I.T. not be used in advertising or
  17.  * publicity pertaining to distribution of the software without specific,
  18.  * written prior permission.  M.I.T. makes no representations about the
  19.  * suitability of this software for any purpose.  It is provided "as is"
  20.  * without express or implied warranty.
  21.  *
  22.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  24.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  25.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  26.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  27.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  28.  */
  29.  
  30. #include <stdio.h>
  31.  
  32. #include <X11/Intrinsic.h>    
  33.  
  34. #include <X11/Xaw/Label.h>    
  35. #include <X11/Xaw/Cardinals.h>    
  36.  
  37. static void Syntax();
  38.  
  39. String fallback_resources[] = { "*Label.Label:    This is xlabel", NULL };
  40.  
  41. /* This is an example of a command line option table.
  42.  * 
  43.  * "-label"          - The command line option to look for.
  44.  * "*Label.label"    - The resource to which the value will be assigned.
  45.  *                     application name is automatically prepended to this
  46.  *                     string.
  47.  * XrmoptionSepArg   - The next arguemnt will be the value for 
  48.  *                     the *Label.label resource.
  49.  * NULL              - UNUSED.
  50.  */
  51.  
  52. static XrmOptionDescRec options[] = {
  53. {"-label",    "*Label.label",    XrmoptionSepArg,    NULL}
  54. };
  55.  
  56. main(argc, argv)
  57. int argc;
  58. char **argv;
  59. {
  60.     XtAppContext app_con;
  61.     Widget toplevel;
  62.  
  63.     toplevel = XtAppInitialize(&app_con, "Xlabel", options, XtNumber(options),
  64.                    &argc, argv, fallback_resources,
  65.                    NULL, ZERO);
  66.  
  67.     /*
  68.      * Check to see that all arguments were processed, and if not then
  69.      * report an error and exit.
  70.      */
  71.  
  72.     if (argc != 1)        
  73.     Syntax(app_con, argv[0]);
  74.  
  75.  
  76.     (void) XtCreateManagedWidget("label", labelWidgetClass, toplevel, 
  77.                  NULL, ZERO);
  78.     XtRealizeWidget(toplevel);
  79.     XtAppMainLoop(app_con);
  80. }
  81.  
  82. /*    Function Name: Syntax
  83.  *    Description: Prints a the calling syntax for this function to stdout.
  84.  *    Arguments: app_con - the application context.
  85.  *                 call - the name of the application.
  86.  *    Returns: none - exits tho.
  87.  */
  88.  
  89. static void 
  90. Syntax(app_con, call)
  91. XtAppContext app_con;
  92. char *call;
  93. {
  94.     XtDestroyApplicationContext(app_con);
  95.     fprintf( stderr, "Usage: %s [-label <label name>]\n", call);
  96.     exit(1);
  97. }
  98.